package cn.singno.springBoot.demo.ch10_asyncTask;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
@ComponentScan("cn.singno.springBoot.demo.ch10_asyncTask")
@EnableAsync
public class TaskExecutorConfig implements AsyncConfigurer
{
	@Override
        public Executor getAsyncExecutor()
        {
	        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
	        threadPoolTaskExecutor.setCorePoolSize(5);
	        threadPoolTaskExecutor.setMaxPoolSize(10);
	        threadPoolTaskExecutor.setQueueCapacity(25);
	        threadPoolTaskExecutor.initialize();
	        return threadPoolTaskExecutor;
        }

	@Override
        public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
        {
	        
	        return null;
        }
}
